<style lang="less">
  @import "./home.less";
  @import "../styles/common.less";
</style>
<template>
  <div class="home-main">
    <Row :gutter="10">
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}" v-if="dashboard_person_arr.indexOf('taskList') > -1">
      <infor-card
        @clickFunction="count_task_fun()"
        id-name="count_task"
        :end-val="count.task"
        iconType="ios-eye"
        color="#f25e43"
        intro-text="我的任务"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="dashboard_person_arr.indexOf('task_delayed') > -1">
      <infor-card
        @clickFunction="count_delaytask_fun()"
        id-name="count_delaytask"
        :end-val="count.delaytask"
        iconType="ios-eye"
        color="#f44336"
        intro-text="我的延期任务"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}" v-if="dashboard_person_arr.indexOf('apply') > -1">
      <infor-card
        @clickFunction="count_apply_fun()"
        id-name="count_apply"
        :end-val="count.apply"
        iconType="ios-eye"
        color="#4caf50"
        intro-text="我的申办"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}" v-if="dashboard_person_arr.indexOf('calendar') > -1">
      <infor-card
        @clickFunction="count_schedule_fun()"
        id-name="count_schedule"
        :end-val="count.schedule"
        iconType="ios-eye"
        color="#f25e43"
        :iconSize="50"
        intro-text="我的日程"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}" v-if="dashboard_person_arr.indexOf('approval') > -1">
      <infor-card
        @clickFunction="count_approval_fun()"
        id-name="count_approval"
        :end-val="count.approval"
        iconType="ios-eye"
        color="#ffd572"
        intro-text="我的审批"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="dashboard_person_arr.indexOf('knowledgeRepo') > -1">
      <infor-card
        @clickFunction="count_knowledge_fun()"
        id-name="count_knowledge"
        :end-val="count.knowledge"
        iconType="ios-eye"
        color="#e91e63"
        intro-text="我的知识库"
      ></infor-card>
      </Col>
    </Row>
    <Row :gutter="10">
      <!--部门统计-->
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('task') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_task"
        :end-val="count.dep_task"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门任务"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('task_delayed') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_delaytask"
        :end-val="count.dep_delaytask"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门延期任务"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('apply') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_apply"
        :end-val="count.dep_apply"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门申办"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('schedule') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_schedule"
        :end-val="count.dep_schedule"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门日程"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('approval') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_approval"
        :end-val="count.dep_approval"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门审批"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('knowledge') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_knowledge"
        :end-val="count.dep_knowledge"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门知识库"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('published') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_published"
        :end-val="count.dep_published"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门发表"
      ></infor-card>
      </Col>
      <Col :sm="6" :md="6" :lg="6" :style="{marginBottom: '10px'}"
           v-if="isVolunteer != true && dashboard_department_arr.indexOf('checking_in') > -1">
      <infor-card
        @clickFunction=""
        id-name="count_dep_checking_in"
        :end-val="count.dep_checking_in"
        iconType="ios-podium-outline"
        color="#2d8cf0"
        intro-text="部门考勤"
      ></infor-card>
      </Col>
    </Row>
    <Row :gutter="10" class="margin-top-10" v-if="isVolunteer != true">
      <Col :xs="24" :sm="12" :md="12" :lg="12" :style="{marginBottom: '10px'}"
           v-if="dashboard_department_arr.indexOf('schedule') > -1">
      <Card>
        <div class="data-source-row">
          <Carousel v-model="modelCarousel_schedule" loop>
            <CarouselItem v-for="(el,index) in dep_schedule_arr" :key="index">
              <div class="chart-carousel">
                <visite-volume
                  :visite_volume_id="el.id"
                  :xDataTitle="el.title"
                  :xDataArr="el.xDataArr"
                  :yDataArr="el.yDataArr"
                  :div_width="charts_div_width"
                ></visite-volume>
              </div>
            </CarouselItem>
          </Carousel>
        </div>
      </Card>
      </Col>
      <Col :xs="24" :sm="12" :md="12" :lg="12" :style="{marginBottom: '10px'}"
           v-if="dashboard_department_arr.indexOf('task') > -1">
      <Card>
        <div class="data-source-row">
          <Carousel v-model="modelCarousel_task" loop>
            <CarouselItem v-for="(el,index) in dep_task_arr" :key="index">
              <div class="chart-carousel">
                <visite-volume
                  :visite_volume_id="el.id"
                  :xDataTitle="el.title"
                  :xDataArr="el.xDataArr"
                  :yDataArr="el.yDataArr"
                  :div_width="charts_div_width"
                ></visite-volume>
              </div>
            </CarouselItem>
          </Carousel>
        </div>
      </Card>
      </Col>
      <Col :xs="24" :sm="12" :md="12" :lg="12" :style="{marginBottom: '10px'}"
           v-if="dashboard_department_arr.indexOf('knowledge') > -1">
      <Card>
        <div class="data-source-row">
          <Carousel v-model="modelCarousel_knowledge" loop>
            <CarouselItem v-for="(el,index) in dep_knowledge_arr" :key="index">
              <div class="chart-carousel">
                <visite-volume
                  :visite_volume_id="el.id"
                  :xDataTitle="el.title"
                  :xDataArr="el.xDataArr"
                  :yDataArr="el.yDataArr"
                  :div_width="charts_div_width"
                ></visite-volume>
              </div>
            </CarouselItem>
          </Carousel>
        </div>
      </Card>
      </Col>
    </Row>
    <Row :gutter="10" class="margin-top-10">
      <Col :xs="24" :sm="24" :md="24" :lg="24" :style="{marginBottom: '10px'}">
      <Card>
        <div class="img-apk-div">
          <div class="img-div">
            <img class="img-left" src="/vendors/images/login.png">
          </div>
          <div class="img-div">
            <img class="img-right" src="/vendors/images/work.png">
          </div>
          <div class="img-div-apk">
            <div class="title-div-up">
              <img class="img-code" src="/vendors/images/app.png" alt="点击下载apk安装包" title="点击下载apk安装包"
                   @click="apkDownloadFile()">
              <div>点击下载apk安装包</div>
            </div>
            <div class="title-div-down">
              <img class="img-code" src="/vendors/images/weixin.jpg" alt="关注微信公众号" title="关注微信公众号">
              <div>关注企业微信公众号</div>
            </div>
          </div>
        </div>
      </Card>
      </Col>
    </Row>
  </div>
</template>

<script>
  import cityData from './map-data/get-city-value.js';
  import homeMap from './components/map.vue';
  import dataSourcePie from './components/dataSourcePie.vue';
  import visiteVolume from './components/visiteVolume.vue';
  import serviceRequests from './components/serviceRequests.vue';
  import userFlow from './components/userFlow.vue';
  import countUp from './components/countUp.vue';
  import inforCard from './components/inforCard.vue';
  import mapDataTable from './components/mapDataTable.vue';
  import toDoListItem from './components/toDoListItem.vue';
  import Cookies from 'js-cookie';
  import util from '@/libs/util.js';
  import Util from '../../libs/util';
  import Utils from '../../libs/mod.utils';

  export default {
    name: 'home',
    components: {
      homeMap,
      dataSourcePie,
      visiteVolume,
      serviceRequests,
      userFlow,
      countUp,
      inforCard,
      mapDataTable,
      toDoListItem
    },
    data () {
      return {
        count: {
          isVolunteer: false,//是否是志愿者
          is_leadership: false,//领导
          apply: 0,
          task: 0,
          delaytask: 0,
          approval: 0,
          schedule: 0,
          knowledge: 0,
          dep_apply: 0,
          dep_published: 0,
          dep_task: 0,
          dep_delaytask: 0,
          dep_schedule: 0,
          dep_approval: 0,
          dep_knowledge: 0,
          dep_checking_in: 0,
        },
        autoplaySpeed: 4000,
        modelCarousel_schedule: 0,
        modelCarousel_task: 0,
        modelCarousel_knowledge: 0,
        dep_schedule_arr: [],
        dep_task_arr: [],
        dep_knowledge_arr: [],
        dashboard_person_arr: [],
        dashboard_department_arr: [],
        charts_div_width: 350,
      };
    },
    computed: {},
    mounted: function () {
      var _this = this;
    },
    beforeCreate: function () {
      var _this = this;
    },
    beforeMount: function () {
      var _this = this;
    },
    beforeUpdate: function () {
      var _this = this;
    },
    updated: function () {
      var _this = this;
    },
    beforeDestroy: function () {
      var _this = this;
    },
    destroyed: function () {
      var _this = this;
    },
    created: function () {
      var _this = this;
      _this.$nextTick(function () {
        var mainWidth = $('#main').width();
        var charts_div_width = ( mainWidth - 100 - 32 - 32 - 2 ) / 2;
        if (charts_div_width > 350) {
          _this.charts_div_width = charts_div_width;
        }
      });

      _this.is_leadership = Utils.is_leadership();
      var isVolunteer = Util.toJson(localStorage.getItem('userInfo')).isVolunteer || false;
      _this.isVolunteer = isVolunteer;

      _this.getSetup_person();// 个人设置
      if (_this.is_leadership) {
        _this.getSetup_department();// 部门设置
      }
      if (isVolunteer == true) {// 是志愿者
        _this.get_count_task_fun();
        _this.get_count_delaytask_fun();
        _this.get_count_apply_fun();
        _this.get_count_approval_fun();
        _this.get_count_approval_fun();
        _this.get_count_schedule_fun();
        _this.get_count_knowledge_fun();
      } else {
        _this.get_count_task_fun();
        _this.get_count_delaytask_fun();
        _this.get_count_apply_fun();
        _this.get_count_approval_fun();
        _this.get_count_approval_fun();
        _this.get_count_schedule_fun();
        _this.get_count_knowledge_fun();
        // 部门
        _this.get_count_dep_apply_fun();
        _this.get_count_dep_published_fun();
        _this.get_count_dep_task_fun();
        _this.get_count_dep_delaytask_fun();
        _this.get_count_dep_schedule_fun();
        _this.get_count_dep_approval_fun();
        _this.get_count_dep_knowledge_fun();
        _this.get_count_dep_checking_in_fun();
        // 统计图
        _this.get_chart_dep_schedule();
        _this.get_chart_dep_task();
        _this.get_chart_dep_knowledge();
      }
    },
    methods: {
      // 下载安装包
      apkDownloadFile: function () {
        var _this = this;
        var url = Util.app_apk_url;
        Utils.DownloadFile(url, 'app.apk');
      },
      // 个人设置
      getSetup_person () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          type: 'person',
        };
        var params = {
          url: '/dashboard/storage',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data;
            if (!data.length > 0) {
              data = Util.constant.dashboard_person;
            }
            _this.dashboard_person_arr = data;
          } else {
            _this.$Message.error('查询信息失败!');
          }
        }
      },
      // 部门设置
      getSetup_department () {
        var _this = this;
        var data = {
          uid: Util.toJson(localStorage.getItem('userInfo')).id,
          type: 'department',
        };
        var params = {
          url: '/dashboard/storage',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data;
            if (!data.length > 0) {
              data = Util.constant.dashboard_department;
            }
            _this.dashboard_department_arr = data;
          } else {
            _this.$Message.error('查询信息失败!');
          }
        }
      },
      // 任务点击
      count_task_fun: function () {
        var _this = this;
        util.openNewPage(_this, 'task_index');
        _this.$router.push({
          name: 'task_index'
        });
      },
      // 延期任务点击
      count_delaytask_fun: function () {
        var _this = this;
        util.openNewPage(_this, 'task_index');
        _this.$router.push({
          name: 'task_index'
        });
      },
      // 我的申办点击
      count_apply_fun: function () {
        var _this = this;
        localStorage.setItem('approval_type', 'apply');//我申请的
        util.openNewPage(_this, 'approval_index');
        _this.$router.push({
          name: 'approval_index'
        });
      },
      // 审批点击
      count_approval_fun: function () {
        var _this = this;
        localStorage.setItem('approval_type', 'approving');//待我审批的
        util.openNewPage(_this, 'approval_index');
        _this.$router.push({
          name: 'approval_index'
        });
      },
      // 日程点击
      count_schedule_fun: function () {
        var _this = this;
        util.openNewPage(_this, 'schedule_index');
        _this.$router.push({
          name: 'schedule_index'
        });
      },
      // 知识库点击
      count_knowledge_fun: function () {
        var _this = this;
        util.openNewPage(_this, 'knowledge_index');
        _this.$router.push({
          name: 'knowledge_index'
        });
      },
      // 任务统计
      get_count_task_fun: function () {
        var _this = this;
        var data = {
          type: 'taskList',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.task = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 延期任务统计
      get_count_delaytask_fun: function () {
        var _this = this;
        var data = {
          type: 'task_delayed',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.delaytask = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 审批统计
      get_count_approval_fun: function () {
        var _this = this;
        var data = {
          type: 'approval',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.count || 0;
            _this.count.approval = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 我的申办统计
      get_count_apply_fun: function () {
        var _this = this;
        var data = {
          type: 'apply',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.apply = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 日程统计
      get_count_schedule_fun: function () {
        var _this = this;
        var data = {
          type: 'calendar',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.schedule = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 知识库统计
      get_count_knowledge_fun: function () {
        var _this = this;
        var data = {
          type: 'knowledgeRepo',
        };
        var params = {
          url: '/user/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.knowledge = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-申办
      get_count_dep_apply_fun: function () {
        var _this = this;
        var data = {
          type: 'apply',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_apply = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-发表
      get_count_dep_published_fun: function () {
        var _this = this;
        var data = {
          type: 'published',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_published = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-任务
      get_count_dep_task_fun: function () {
        var _this = this;
        var data = {
          type: 'task',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_task = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-延期任务
      get_count_dep_delaytask_fun: function () {
        var _this = this;
        var data = {
          type: 'task_delayed',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_delaytask = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-日程
      get_count_dep_schedule_fun: function () {
        var _this = this;
        var data = {
          type: 'schedule',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_schedule = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-审批
      get_count_dep_approval_fun: function () {
        var _this = this;
        var data = {
          type: 'approval',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_approval = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-知识库
      get_count_dep_knowledge_fun: function () {
        var _this = this;
        var data = {
          type: 'knowledge',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_knowledge = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 部门统计-考勤
      get_count_dep_checking_in_fun: function () {
        var _this = this;
        var data = {
          type: 'checking_in',
        };
        var params = {
          url: '/department/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var total = data.total || 0;
            _this.count.dep_checking_in = total;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 统计图-部门日程
      get_chart_dep_schedule: function () {
        var _this = this;
        var data = {
          type: 'schedule',
          isDepartment: true,
        };
        var params = {
          url: '/dashboard/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var dep_arr = [];
            for (var k in data) {
              if (!data[k]) {
                continue;
              }
              var timestamp = new Date().getTime();
              var random = Utils.getRandom();
              var title = data[k].title;
              var list = data[k].list;
              var xArr = [];
              var yArr = [];
              for (var l in list) {
                if (!list[l]) {
                  continue;
                }
                var name = list[l].name;
                var value = list[l].value;
                xArr.push(name);
                yArr.push(value);
              }
              var obj = {
                id: timestamp + random,
                title: title,
                xDataArr: xArr,
                yDataArr: yArr,
              };
              dep_arr.push(obj);
            }
            _this.dep_schedule_arr = dep_arr;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 统计图-部门任务
      get_chart_dep_task: function () {
        var _this = this;
        var data = {
          type: 'task',
          isDepartment: true,
        };
        var params = {
          url: '/dashboard/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var dep_arr = [];
            for (var k in data) {
              if (!data[k]) {
                continue;
              }
              var timestamp = new Date().getTime();
              var random = Utils.getRandom();
              var title = data[k].title;
              var list = data[k].list;
              var xArr = [];
              var yArr = [];
              for (var l in list) {
                if (!list[l]) {
                  continue;
                }
                var name = list[l].name;
                var value = list[l].value;
                xArr.push(name);
                yArr.push(value);
              }
              var obj = {
                id: timestamp + random,
                title: title,
                xDataArr: xArr,
                yDataArr: yArr,
              };
              dep_arr.push(obj);
            }
            _this.dep_task_arr = dep_arr;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
      // 统计图-部门知识库
      get_chart_dep_knowledge: function () {
        var _this = this;
        var data = {
          type: 'knowledge',
          isDepartment: true,
        };
        var params = {
          url: '/dashboard/statistics',
          type: Util.method.get,
          data: data,
          success: _successFun
        };
        Util.ajax(_this, params);
        function _successFun(res) {
          if (res.result == 0) {
            var data = res.data || [];
            var dep_arr = [];
            for (var k in data) {
              if (!data[k]) {
                continue;
              }
              var timestamp = new Date().getTime();
              var random = Utils.getRandom();
              var title = data[k].title;
              var list = data[k].list;
              var xArr = [];
              var yArr = [];
              for (var l in list) {
                if (!list[l]) {
                  continue;
                }
                var name = list[l].name;
                var value = list[l].value;
                xArr.push(name);
                yArr.push(value);
              }
              var obj = {
                id: timestamp + random,
                title: title,
                xDataArr: xArr,
                yDataArr: yArr,
              };
              dep_arr.push(obj);
            }
            _this.dep_knowledge_arr = dep_arr;
          } else {
            _this.$Message.error('统计信息失败!');
          }
        }
      },
    }
  };
</script>
